1 //------------------------------------------------------------------------------
2 // <copyright file="DelegateWrappers.cs" company="Microsoft">
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
14 //------------------------------------------------------------------------------
17 using System
.Runtime
.InteropServices
;
19 namespace SharedSourceCLI
.TK
21 internal class TclAppInitProcWrapper
{
25 Tcl_AppInitProc _callback
;
27 internal TclAppInitProcWrapper(TclInterp interp
, TclAppInitProc proc
) {
30 unsafe { _callback = new Tcl_AppInitProc(this.CallbackProc); }
33 internal Tcl_AppInitProc Callback
{
34 get { return _callback; }
37 private unsafe int CallbackProc(Tcl_Interp
* interp
)
43 return TclNative
.TCL_ERROR
;
46 return TclNative
.TCL_OK
;
50 internal class TclCmdProcWrapper
{
54 Tcl_CmdProc _callback
;
56 internal TclCmdProcWrapper(TclInterp interp
, TclCmdProc proc
) {
59 unsafe { _callback = new Tcl_CmdProc(this.CallbackProc); }
62 internal Tcl_CmdProc Callback
{
63 get { return _callback; }
66 private unsafe int CallbackProc(IntPtr clientData
,
67 Tcl_Interp
* interp
, int argc
, char** argv
)
70 string[] arr
= new string[argc
];
71 for(int i
=0; i
<argc
; i
++)
73 arr
[i
] = Marshal
.PtrToStringAnsi((IntPtr
)argv
[i
]);
79 return TclNative
.TCL_ERROR
;
82 return TclNative
.TCL_OK
;
86 internal class TclCmdDeleteProcWrapper
{
89 TclCmdDeleteProc _proc
;
90 Tcl_CmdDeleteProc _callback
;
93 internal TclCmdDeleteProcWrapper(TclInterp interp
, TclCmdDeleteProc proc
, Object deletee
) {
96 unsafe { _callback = new Tcl_CmdDeleteProc(this.CallbackProc); }
99 _interp
.AddKeepAlive(this);
100 _interp
.AddKeepAlive(_deletee
);
103 internal Tcl_CmdDeleteProc Callback
{
104 get { return _callback; }
107 private unsafe int CallbackProc(IntPtr clientData
)
110 _interp
.RemoveKeepAlive(_deletee
);
111 _interp
.RemoveKeepAlive(this);
117 return TclNative
.TCL_ERROR
;
120 return TclNative
.TCL_OK
;